#include "textlabel.h"
#include "textcontext.h"
#include "engine/GameSystem.h"
#include <string.h>

TextLabel::TextLabel():
        _substring(0)
{
}

TextLabel::~TextLabel(){
}

void TextLabel::setContext(TextContext * context){
    _context = context;
    _context->setText(this);
}

XCHAR * TextLabel::getSubstring(int from, int to){
    int n = to - from;
    if( n <= 0)
        return 0;
    if(n > strlen(_text))
        n = strlen(_text);
    delete [] _substring;
    _substring = new XCHAR[n + 1];
    GameSystem::strCopyEx(_substring, _text, from, to);
    _substring[n] = '\0';
    return _substring;
}
